package com.xxxx.Mytest

/**
 * @program: test01
 * @description: 九九乘法表
 * @author: CoreDao
 * @create: 2021-03-02 16:14
 **/


object NineX {
  def main(args: Array[String]): Unit = {
    var sum = 1
    for (i <- 1 to 9){
      for (j <- 1 to i){
        sum = i*j
        //printf("%d x %d = %d ",i,j,sum)
        /**
         * s""表示要引用变量值，一般会出现$
         */
        print(s"$j*$i=$sum\t")
        if(i==j)
          println()
      }
    }

    /**
     * for {子句} yield {变量或表达式}
     * yield
     * ctrl + alt + v
     * 显式类型
     */

    val ints = for (i <- 1 to 10; if i > 5) yield i + 2
    ints.foreach(println())

    val ints1 = for (i <- 1 to 10; if 1 > 5) yield 2
    for (w <- ints1){
      println(w)
    }

  }
}
